package myjava.objects_rock;

public class Ball {

   private int diameter;

   public Ball(int d) {
      this.diameter = d;
   }

   @Override
   public boolean equals(Object o) {

      if (o instanceof Ball) {
         if (this.diameter == ((Ball) o).diameter) {
            return true;
         } else {
            return false;
         }
      } else {
         return false;
      }
   }

   // if 2 objects are evaluated identical usign equals then they MUST have the same hashcode!
   @Override
   public int hashCode() {
      return this.diameter;
   }
}